home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 21.zip / BS1 part 21 / Professional Page v4.0 (1993)(Gold Disk)(Disk 1 of 4)[HD].7z / Professional Page v4.0 (1993)(Gold Disk)(Disk 1 of 4)[HD].adf / rexx.lzh / counter.rexx < prev    next >
OS/2 REXX Batch file  |  1992-03-13  |  1KB  |  42 lines

  1. /*
  2.    Counter.rexx Copyright Gold Disk Inc., February, 1992
  3.    This macro keeps a running counter. It is useful for enumerating values
  4.    such as lines, page numbers etc.
  5.    Use it in the following manner with mergecodes
  6.    a.   First initialize a counter by calling the function with a new name
  7.            example: ««=counter.rexx(newname,1)»».
  8.         This will initialize a new counter named newname with a value of one.
  9.         When the ReplaceMergeCodes Genie is run, the entire string will be 
  10.         replaced by the value of 1.
  11.    b.    Call this function whenever the next value is needed:
  12.            Example:
  13. */
  14.  
  15. parse arg counter, init, incfunc
  16.  
  17. if init ~= '' then
  18. do
  19.     val = init
  20.     call setclip(ppuser_counter||counter, init)
  21. end
  22. else
  23. do
  24.     val = getclip(ppuser_counter||counter)
  25.     if val = '' then val = 0
  26. end
  27.  
  28. if incfunc ~= '' then
  29.     call setclip(ppuser_func||counter, incfunc)
  30. else
  31.     incfunc = getclip(ppuser_func||counter)
  32.  
  33. rval = val
  34.  
  35. if incfunc ~= '' then 
  36.     interpret "val = val "incfunc
  37. else 
  38.     val = val + 1
  39.  
  40. call setclip(ppuser_counter||counter, val)
  41. return(rval)
  42.